home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / Buildable, limited OOFILE / source / GUI / Mac / PPlant / Extras / LControlEnablingEditField.h < prev    next >
Encoding:
Text File  |  1995-09-30  |  2.0 KB  |  75 lines  |  [TEXT/CWIE]

  1. // LControlEnablingEditField
  2. // enables and disables the attached LControl when the field is empty
  3. // ©1995 A.D. Software, all rights reserved
  4. // freely licensed for any use
  5. // contact dent@highway1.com.au  or http://www.highway1.com.au/adsoftware/
  6.  
  7. /*
  8.      INSTRUCTIONS
  9.     in FinishCreateSelf()
  10. 1)
  11.     create the control with a cast like:
  12.         mFindField = (LControlEnablingEditField *)FindPaneByID('Edit');
  13.  
  14.     instead of the normal
  15.         mFindField = (LEditField *)FindPaneByID('Edit');
  16.  
  17. 2)
  18.     tell the field which control it enables, eg:
  19.         mFindField->enablesControl(mFindButton);
  20.  
  21. 3)    
  22.     if you want to reverse the sense of when the control should be enabled/disabled
  23.         mFindField->disableWhenEmpty()
  24.  
  25. */
  26.  
  27. #pragma once
  28.  
  29. #include <LEditField.h>
  30.  
  31. class LControl;
  32.  
  33. class LControlEnablingEditField : public LEditField {
  34. public:
  35.     enum { class_ID = 'ened' };
  36.     static LControlEnablingEditField*    CreateControlEnablingEditFieldStream(LStream *inStream);
  37.  
  38.                         LControlEnablingEditField();
  39.                         LControlEnablingEditField(
  40.                                 const LControlEnablingEditField    &inOriginal);
  41.                         LControlEnablingEditField(
  42.                                 const SPaneInfo        &inPaneInfo,
  43.                                 Str255                inString,
  44.                                 ResIDT                inTextTraitsID,
  45.                                 Int16                inMaxChars,
  46.                                 Boolean                inHasBox,
  47.                                 Boolean                inHasWordWrap,
  48.                                 KeyFilterFunc        inKeyFilter,
  49.                                 LCommander            *inSuper);
  50.                         LControlEnablingEditField(
  51.                                 const SPaneInfo        &inPaneInfo,
  52.                                 Str255                inString,
  53.                                 ResIDT                inTextTraitsID,
  54.                                 Int16                inMaxChars,
  55.                                 Uint8                inAttributes,
  56.                                 KeyFilterFunc        inKeyFilter,
  57.                                 LCommander            *inSuper);
  58.                         LControlEnablingEditField(
  59.                                 LStream                *inStream);
  60.     virtual                ~LControlEnablingEditField() {};
  61.     
  62.     
  63.     virtual void        UserChangedText();  // the main reason for our existence!
  64.     
  65.     LControl*    enablesControl();
  66.     void        enablesControl(LControl*);
  67.     
  68.     Boolean        enablesWhenEmpty();
  69.     void        enableWhenEmpty();
  70.     void        disableWhenEmpty();  // default case
  71.                 
  72. private:
  73.     LControl*    mEnablingTarget;
  74.     Boolean        mEnableWhenEmpty;
  75. };